package com.lineage.data.item_etcitem.shop;

import com.lineage.data.executor.ItemExecutor;
import com.lineage.server.model.Instance.L1ItemInstance;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.serverpackets.S_ServerMessage;
import com.lineage.server.serverpackets.S_SystemMessage;
import com.lineage.server.serverpackets.ServerBasePacket;

public class SealScrolls extends ItemExecutor {
  public static ItemExecutor get() {
    return new SealScrolls();
  }
  
  public void execute(int[] data, L1PcInstance pc, L1ItemInstance item) {
    int itemobj = data[0];
    L1ItemInstance tgitem = pc.getInventory().getItem(itemobj);
    if (tgitem == null)
      return; 
    if (tgitem.getItem().getType2() == 0) {
      pc.sendPackets((ServerBasePacket)new S_ServerMessage("\\aE只能对武器装备使用！"));
      return;
    } 
    if (tgitem.isSeal()) {
      tgitem.setSeal(false);
      pc.getInventory().updateItem(tgitem, 
          4096);
      pc.getInventory().saveItem(tgitem, 
          4096);
      pc.getInventory().removeItem(item, 1L);
      pc.sendPackets((ServerBasePacket)new S_SystemMessage(String.valueOf(tgitem.getLogName()) + "\\aI解除绑定成功！"));
      return;
    } 
    tgitem.setSeal(true);
    pc.getInventory().updateItem(tgitem, 
        4096);
    pc.getInventory().saveItem(tgitem, 
        4096);
    pc.sendPackets((ServerBasePacket)new S_SystemMessage(String.valueOf(tgitem.getLogName()) + "\\aD绑定成功！"));
    pc.sendPackets((ServerBasePacket)new S_SystemMessage("\\aE死亡不会掉落 不会消失"));
    pc.getInventory().removeItem(item, 1L);
  }
}
